version: 'latest'
services:
  flask1:
    build: ./flask1
    container_name: docker1
    environment:
      - PYTHONUNBUFFERED=True                   
    restart: on-failure
    volumes:
      - ./flask1:/flask1
    ports:
      - "5001"
    networks:
      - internal_network
      - external_network
    command: python app.py
    extra_hosts:
      - "flask:0.0.0.0"

  flask2:
    build: ./flask2
    container_name: docker2
    environment:
      - PYTHONUNBUFFERED=True                   
    restart: on-failure
    volumes:
      - ./flask2:/flask2
    ports:
      - "5002"
    networks:
      - internal_network
      - external_network
    command: python app.py
    extra_hosts:
      - "flask:0.0.0.0"

  balancer:
    build: ./balancer
    container_name: balancer
    ports:
      - "5000:5000" 
      - "5003:5000"
      - "443:443"
    volumes:
      - ./balancer/nginx.conf:/etc/nginx/nginx.conf  
    networks:
      - external_network
      - internal_network
    extra_hosts:
      - "flask:0.0.0.0"
networks:
  internal_network:
    driver: bridge
  external_network:
    driver: bridge